package com.zbf.config;

import com.zbf.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/5/25  16:07
 * 描述:
 */
@Configuration
@EnableConfigurationProperties(TestUploadProperties.class)
@ConditionalOnClass
public class TestUploadAutoConfiguration {

    @Autowired
    private TestUploadProperties testUploadProperties;

    @Bean
    @ConditionalOnProperty(prefix = "com.zbf",name = "enable",havingValue = "true")
    public UploadService getUploadService(){

        UploadService uploadService=new UploadService();
        uploadService.setPath(testUploadProperties.getPath());

        return uploadService;
    }

}
